<?php $this->_extends('../_layouts/default_layout'); ?>
<?php $this->_block('contents'); ?>
<script type="text/javascript" src="<?=Q::ini('custom_system/base_url');?>js/json.js"></script>
<script type="text/javascript">
$(function(){
	$(".info").colorbox({width:"50%", height:"70%", iframe:true});
	var old_info;
	$(".edit").click(function(){
		var container = $(this).parent().parent();
		old_info = container.find("input.blur").val();
		container.find("input.blur").focus().blur(function(){
			var id = $(this).next().val();
			var new_info = $(this).val();
			if (new_info != old_info)
			{
				if ($(this).attr("name") == 'position')
				{
					var url = "<?=url('Storage::Product/ProductShelfPositionEditSave')?>&position=" + new_info;
				}
				$.ajax({
					url: url + "&id=" + id,
					type: "GET",
					dataType: "json",
					success:
						function(data)
						{
							current_tag.addClass("blur");
						}
				});
			}
		});
	});
});
</script>
<style>
.blur
{
	cursor: pointer;
	border: none;
}
</style>
<fieldset><legend>查询条件</legend>
<form method="get">
<?include(Q::ini('custom_system/elements_dir') . 'searchform_element.php');?>
<table class="form_table">
<tr>
	<th>架位名称</th>
	<td><input type="text" name="position_name" value="<?=isset($_GET['position_name']) ? $_GET['position_name'] : ''?>" /></td>
</tr>
<tr>
	<th>产品编号数量</th>
	<td>
		<select name="product_number_quantity_operator">
			<option value="">请选择..</option>
			<option value="=" <?if(isset($_GET['product_number_quantity_operator'])&&$_GET['product_number_quantity_operator']=='=')echo "selected='selected'"?>>=</option>
			<option value=">=" <?if(isset($_GET['product_number_quantity_operator'])&&$_GET['product_number_quantity_operator']=='>=')echo "selected='selected'"?>>&gt;=</option>
			<option value="<=" <?if(isset($_GET['product_number_quantity_operator'])&&$_GET['product_number_quantity_operator']=='<=')echo "selected='selected'"?>>&lt;=</option>
		</select>
		<input type="text" name="product_number_quantity" value="<?=isset($_GET['product_number_quantity']) ? $_GET['product_number_quantity']:''?>" />
	</td>
</tr>
<tr>
	<th>产品数量</th>
	<td>
		<select name="product_quantity_operator">
			<option value="">请选择..</option>
			<option value="=" <?if(isset($_GET['product_quantity_operator'])&&$_GET['product_quantity_operator']=='=')echo "selected='selected'"?>>=</option>
			<option value=">=" <?if(isset($_GET['product_quantity_operator'])&&$_GET['product_quantity_operator']=='>=')echo "selected='selected'"?>>&gt;=</option>
			<option value="<=" <?if(isset($_GET['product_quantity_operator'])&&$_GET['product_quantity_operator']=='<=')echo "selected='selected'"?>>&lt;=</option>
		</select>
		<input type="text" name="product_quantity" value="<?=isset($_GET['product_quantity']) ? $_GET['product_quantity']:''?>" />
	</td>
</tr>
<tr>
	<td></td>
	<td><input type="submit" class="button" value="查询" /></td>
</tr>
</table>
</form>
</fieldset>
<table width="50%" class="list_table">
<tr>
	<th>ID</th>
	<th>架位</th>
	<th>产品编号数</th>
	<th>产品现存数</th>
	<th width="150">操作</th>
</tr>
<?foreach ($product_shelf_position as $psp):?>
<tr>
	<td><?=$psp['id']?></td>
	<td>
		<input type="text" name="position" value="<?=$psp['position']?>" class="blur edit" />
		<input type="hidden" value="<?=$psp['id']?>" />
	</td>
	<td><?=$psp['product_number_quantity']?></td>
	<td><?=$psp['product_quantity']?></td>
	<td >
	<a class="edit">编辑</a>
	<a href="<?=url('Storage::Product/ProductShelfPositionDelete', array('id'=>$psp['id']))?>" onclick="if( ! confirm('确定删除')) return false;">删除</a>
	<a class="info" href="<?=url('Storage::Product/ShelfPositionProduct', array('id'=>$psp['id']))?>">查看</a>
	</td>
</tr>
<?endforeach;?>
</table>
<?=$page;?>
<?php $this->_endblock();?>